package com.kgc.student.studentmanagerweb.controller;

import com.kgc.student.bean.Classes;
import com.kgc.student.bean.Student;
import com.kgc.student.service.StuService;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class StuController {

    @Reference
    StuService stuService;
    @RequestMapping("/seleStu")
    public List<Student> seleStu(){
        List<Student> all = stuService.getAll();
        return all;
    }
    @RequestMapping("/seleClass")
    public List<Classes> seleClass(){
        List<Classes> allClasse = stuService.getAllClasse();
        return allClasse;
    }

    @RequestMapping("/addStu")
    public String addStu(@RequestBody Student student){
        int i = stuService.addStu(student);
        if(i>0){
            return "SUCCESS";
        }else{
            return "FAIL";
        }
    }

}
